# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
# This source file is part of the Cangjie project, licensed under Apache-2.0
# with Runtime Library Exception.
#
# See https://cangjie-lang.cn/pages/LICENSE for license information.

from os import path

integer_types = ['Int8', 'Int16', 'Int32', 'Int64', 'IntNative', 'UInt8', 'UInt16', 'UInt32', 'UInt64', 'UIntNative']

dir = path.dirname(path.realpath(__file__))
path = dir + '/test_' + path.basename(dir) + '_{}.cj'
template = '''
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
 * This source file is part of the Cangjie project, licensed under Apache-2.0
 * with Runtime Library Exception.
 *
 * See https://cangjie-lang.cn/pages/LICENSE for license information.
 */

/*
  @Assertion:   4.23(17) This design helps to avoid mistakes where an assignment expression is mistakenly used as an
                equal expression. For instance, given the expression a = b = 0, the expression (a = b) is firstly
                evaluated and the value is (). Next, the expression () = 0 is evaluated. Since () cannot be an assigned
                to, an error is reported.
  @Description: %s
  @Mode: %s
  @Negative: %s
  @Structure: single
  @CompileWarning: ignore
  @Comment: Auto-generated by gen.py
*/
%s'''
negative_template = template % ('Checks that expression a = b = 0 is invalid for type {t}.', 'compileonly', 'yes', '''
main() {{
    var a : {t} = 1
    var b : {t} = 2
    a = b = 0
    0
}}
''')
counter = 1

def write_counted(contents : str):
  global counter
  with open(path.format(str(counter).zfill(2)), 'w') as file:
    file.write(contents)
    counter += 1

for test in [negative_template.format(t=t) for t in integer_types]:
  write_counted(test)